package com.edu.course.controller;


import com.edu.course.service.IHfdClassInfoService;
import com.edu.course.service.IHfdClassSkuInfoService;
import com.edu.entity.HfdClassInfo;
import com.edu.entity.HfdClassSkuInfo;
import com.edu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 班级表 前端控制器
 * </p>
 *
 * @author jr
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/course")
public class HfdClassInfoController {

    @Autowired
    private IHfdClassInfoService iHfdClassInfoService;

    @Autowired
    private IHfdClassSkuInfoService iHfdClassSkuInfoService;

    /**
     * 查询数据库中所有班级class的信息，准备同步到es库
     * @return
     */

    @RequestMapping("/findClassInfo")
    public List<HfdClassInfo> findClassInfo(){
        return iHfdClassInfoService.findClassInfo();
    }

    /**
     * 通过Class中cid去下一个页面查询具体的班级信息
     * @param cid
     * @return
     */
    @RequestMapping("/findClassSkuInfoByCid")
    public List<HfdClassSkuInfo> findClassSkuInfoByCid(Integer cid){
        return iHfdClassSkuInfoService.findClassSkuInfoByCid(cid);
    }

    @RequestMapping("/findClassSkuInfoBySkuId")
    public HfdClassSkuInfo findClassSkuInfoBySkuId(Integer skuId){
        return iHfdClassSkuInfoService.findClassSkuInfoBySkuId(skuId);
    }

    /**
     * 获取当前用户已购买的课程信息
     * @return
     */
    @RequestMapping("/getMyClass")
    public Result getMyClass(){
        return iHfdClassSkuInfoService.getMyClass();
    }



}
